﻿CREATE FUNCTION dbo.NotesToolTip
	(
	@LoanID int
	)
RETURNS varchar(8000)
AS
BEGIN

DECLARE @NoteID int,@Text varchar(8000)

SELECT TOP 1 @NoteID = ID,@Text = '- '+Note FROM  t_Notes WHERE (LoanID = @LoanID) ORDER BY ID

WHILE @@ROWCOUNT > 0 BEGIN
	SET @Text = @Text + CHAR(13)
	SELECT TOP 1 @NoteID = ID,@Text = @Text + '- '+Note FROM  t_Notes WHERE LoanID = @LoanID AND ID > @NoteID  ORDER BY ID

END

RETURN '<SPAN title="'+dbo.HTMLEncode(@Text)+'">Note</SPAN>'
END

